﻿function creatApplyList(roomid) {

    $.post('/MeetingRoomApply/CreatApplyList', { meetingRoomId: roomid },
                function (result) {
                    $("#content").html(result);
                });
}

//弹出预定窗口
function apply(dataquery) {
    $('#dlg').dialog('open').dialog('setTitle', '预定');
    $('#fm').form('clear');
    if (dataquery) {
        $('#MeetingDate').datebox('setValue', dataquery.q_MeetingDate);
        $('#EndTime22').timespinner('setValue', dataquery.q_EndTime);
        $('#StartTime22').timespinner('setValue', dataquery.q_StartTime);

    }
    var roomid = $('#comb_MeetingRoom').combobox('getValue');
    var roomName = $('#comb_MeetingRoom').combobox('getText');
    $('#MeetingRoomName').val(roomName);
    $('#MeetingRoomID').val(roomid);
    url = '/MeetingRoomApply/Create';
}

//保存数据
function save() {
    var end = $('#EndTime22').timespinner('getValue');
    $('#EndTime2').val(end);
    var start = $('#StartTime22').timespinner('getValue');
    $('#StartTime2').val(start);

    $('#fm').form('submit', {
        url: url,
        onSubmit: function () {
            return $(this).form('validate');
        },
        success: function (result) {
            if (result == 'OK') {
                $('#dlg').dialog('close');      // close the dialog  
                $('#list').datagrid('reload');    // reload the user data  

                var id = $('#MeetingRoomID').val();
                var text = $('#MeetingRoomName').val();
                creatApplyList(id);
            } else {
                $.messager.show({
                    title: 'Error',
                    msg: result
                });
            }
        }
    });
}
